// pages/home/index.js
const app = getApp()
const {
  getAdvImg
} = require('../../services/api/common.js')
const {
  showToast
} = require('../../utils/util.js')
Page({
  data: {
    swipers: [{
        id: 1,
        url: '/assets/tmps/home-swiper.jpg'
      },
      {
        id: 2,
        url: '/assets/tmps/home-swiper.jpg'
      },
    ],
    dotIndex: 0,
    offlineCustom: false
  },
  onLoad() {
    this.loadData()

  },
  onShow() {
    app.initPageLang(this)
    this.isOfflineCustom()
  },
  isOfflineCustom() {
    this.setData({
      offlineCustom: app.data.offlineCustom
    })
    app.getUnmakeList(() => {
      this.setData({
        offlineCustom: app.data.offlineCustom
      })
      console.log(this.data.offlineCustom, '1111');
    })
  },
  onSwiperChange({
    detail
  }) {
    // console.log(detail)
    this.setData({
      dotIndex: detail.current
    })
  },
  async loadData() {
    await getAdvImg(2).then(res => {
      if (res.code === 0) {
        const swipers = res.info.advertInfoList.map(x => ({
          id: x.id + '',
          url: x.imgUrl,
          advertisingPositionName: x.advertisingPositionName,
          content: x.content,
          includeSubsets: x.includeSubsets,

        }))
        this.setData({
          swipers
        })
      }
    })
    getAdvImg(12).then(res => {
      if (res.code === 0) {
        console.log(res,"参观须知");
        this.setData({
          visitData: {
            imgUrl:res.info.advertInfoList[0].imgUrl,
            includeSubsets:res.info.advertInfoList[0].includeSubsets,
            advertisingPositionName: res.info.advertInfoList[0].advertisingPositionName,
            content: res.info.advertInfoList[0].content,
          }
        })
      }
    })
  },
  toLink1() {
    showToast(this.data.$language.l215)
  },
  toLink({
    currentTarget: {
      dataset: {
        item
      }
    }
  }) {
    wx.navigateTo({
      url: '/subpackages/home/instructions/index',
     
    })
    
    return 
    app.toTinymceView(item)
  },
  onShareAppMessage() {
    
  }
})